package com.qding.park.common.utils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class Base64 {

//	private static final String CODES = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

	public static boolean GenerateImage(String imgStr,String filepath) {// 对字节数组字符串进行Base64解码并生成图片
		if (imgStr == null) // 图像数据为空
			return false;
		try {
			org.apache.commons.codec.binary.Base64 base=new org.apache.commons.codec.binary.Base64();
			byte[]  b=base.decode(imgStr.getBytes("utf-8"));
			String imgFilePath = filepath;// 新生成的图片
			OutputStream out = new FileOutputStream(imgFilePath);
			out.write(b);
			out.flush();
			out.close();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
}
